package FileIO;

import java.io.IOException;
import java.io.PrintWriter;


public class PrintWriterDemo {
    public static void main(String[] args) {
        /**
         * PrintWriter
         * 继承自Writer
         * 封装了Writer，提供了printf方法
         * 默认情况下，PrintWriter是自动刷新的，即每次调用print()或println()方法时，PrintWriter都会将数据写入到文件中。
         */
        try (PrintWriter printWriter = new PrintWriter("d:/test.txt")) {
            printWriter.printf("%d + %d = %d",10,20,30);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
